/* 
 * File:   Event.cpp
 * Author: aljosa
 * 
 * Created on June 15, 2010, 8:33 AM
 */

#include "Event.h"
#include <cstdlib>
#include <iostream>

using namespace std;

namespace xEngine
{
    namespace CoreSystem
    {
        namespace Events
        {
            //
            // Constructors, destructors
            //

            // Basic event has id of 0
            Event::Event() : type(DEFAULT), data(NULL), autoRelease(false) {
                // Event of id 0, no data(NULL) and is not to be auto-released

            }

            Event::Event(bool autoRelease) : type(DEFAULT), data(NULL), autoRelease(autoRelease) {

            }

            Event::Event(EVENT type, bool autoRelease) : type(type), data(NULL), autoRelease(autoRelease) {

            }

            void Event::print() { // Event informations

                cout<< "-----------" << endl << "Event info: " << endl << "-----------" << endl;
                cout<< "Type: " << this->type << endl;
                cout<< "Autorelease: " << (this->autoRelease ? "true" : "false") <<endl;
                cout<< (data == NULL ? "no data" : "data present") <<endl;
            }


            // Destructor
            Event::~Event() {
                
                // Release data, if present
                if (data) {
                    delete data;
                    data = NULL;
                }
            }
            
        }
    }
}

